package com.luo.ssm.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.luo.ssm.entity.SysFile;
import com.luo.ssm.entity.SysFolder;
import com.luo.ssm.mapper.SysFileMapper;
import com.luo.ssm.service.SysFileService;
import com.luo.ssm.vo.FileVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author : luocheng
 * @date : Created in 2021/8/28 18:11
 * @description :
 */
@Service
public class SysFileServiceImpl implements SysFileService {
    @Autowired
    private SysFileMapper sysFileMapper;

    @Override
    public List<SysFolder> getAllFolder(Integer uid) {
        List<SysFolder> allFolder = sysFileMapper.selectAllFolder(uid);
        return allFolder;
    }

    @Override
    public PageInfo<FileVo> getAllFile(FileVo fileVo, int pageNum, int pageSize) {
        //开启分页插件
        PageHelper.startPage(pageNum,pageSize);
        List<FileVo> fileVos = sysFileMapper.selectAllFile(fileVo);
        PageInfo<FileVo> pageInfo = new PageInfo<>(fileVos);
        return pageInfo;
    }

    @Override
    public int addNewFileInfo(SysFile sysFile) {
        int i = sysFileMapper.insertFileInfo(sysFile);
        return i;
    }
}
